package com.example.dql.diary.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import android.widget.ViewAnimator;

import com.example.dql.diary.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ViewAnimatorActivity extends BaseActivity {


	@BindView(R.id.viewAnimator)
	ViewAnimator viewAnimator;
	@BindView(R.id.tv_animatorOne)
	TextView tvAnimatorOne;
	@BindView(R.id.tv_animatorTwo)
	TextView tvAnimatorTwo;
private Animation in;
private Animation out;
private Animation outLeft;
private Animation inRight;
	@Override
	public int getLayoutId() {
		return R.layout.activity_view_animator;
	}

	@Override
	public Activity bindActivity() {
		return this;
	}

	@Override
	public void init() {
//		Animation out = AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right);
//		viewAnimator.setOutAnimation(out);
		in = AnimationUtils.loadAnimation(this,R.anim.animation_slide_in_left);
		out = AnimationUtils.loadAnimation(this,R.anim.animation_slide_out_right);
		outLeft = AnimationUtils.loadAnimation(this,R.anim.animation_slide_in_right);
		inRight = AnimationUtils.loadAnimation(this,R.anim.animation_slide_out_left);
//		viewAnimator.setOutAnimation(out);
//		viewAnimator.setInAnimation(in);

		viewAnimator.setAnimateFirstView(true);
	}


	@OnClick({R.id.viewAnimator, R.id.btn_nextAnimator,R.id.btn_PreviousAnimator})
	public void onViewClicked(View view) {
		switch (view.getId()) {
			case R.id.viewAnimator:
				break;
			case R.id.btn_nextAnimator:
				viewAnimator.setOutAnimation(out);
				viewAnimator.setInAnimation(in);
				viewAnimator.showNext();
				break;
			case R.id.btn_PreviousAnimator:
				viewAnimator.setOutAnimation(inRight);
				viewAnimator.setInAnimation(outLeft);
				viewAnimator.showPrevious();
				break;

		}
	}
}
